<?php

function model_create_news($bdd, $description, $title,$type_img,$heure) {
 if ($type_img == 3) {
    $req = $bdd->prepare('INSERT INTO news(new_description, new_name,heure) 
        VALUES(:description, :title, :heure)');
    $req->execute(array(
        'description' => $description,
        'title' => $title,
        'heure' => $heure
    ));
 }
 else{$req = $bdd->prepare('INSERT INTO news(new_description, new_name,img_type,heure) 
        VALUES(:description, :title,:img_type,:heure)');
    $req->execute(array(
        'description' => $description,
        'title' => $title,
        'img_type'=> $type_img,
        'heure' => $heure
    ));}
}
function model_create_newsvoid($bdd, $description, $title,$type_img,$heure) {
    $req = $bdd->prepare('INSERT INTO news(new_description, new_name,id_new,heure) 
        VALUES(:description, :title,:id_new,:heure)');
    $req->execute(array(
        'description' => $description,
        'title' => $title,
        'id_new'=>0,
        'heure' =>  $heure
    ));
 }

 function select_id($bdd)
 {
      $results = $bdd->query('  SELECT id_new
FROM news ');
      return $results;
 }
 
 
 
 
 







function count_new($bdd) {
      $req = $bdd->query('SELECT * FROM news');
    $count = $req->rowCount();
    return $count;
}

function select_last_id($bdd) {
    $results = $bdd->query('  SELECT id_new
FROM news 
ORDER BY id_new DESC 
LIMIT 1
    
     ');
    return $results;
}
?>
